package com.itheima.factory;

import com.itheima.dao.Impl.UserDaoImpl;
import com.itheima.dao.UserDao;
import org.springframework.beans.factory.FactoryBean;

/**
 * 实现FactoryBean接口，泛型中写要实例化的bean
 */
public class UserDaoFactoryBean implements FactoryBean<UserDao> {

    //这个方法代替实例化方法
    @Override
    public UserDao getObject() throws Exception {
        return new UserDaoImpl();
    }

    //这个方法知名bean类型
    @Override
    public Class<?> getObjectType() {
        return UserDao.class;
    }

    //单例？
    @Override
    public boolean isSingleton() {
        return true;
    }
}
